MDX Styling Guide for Docusaurus
MDX allows you to use JSX in your markdown content. You can import components, such as interactive charts or alerts, and embed them within your content. This makes writing interactive documentation with Docusaurus a breeze.
1. Standard Markdown Styling
Docusaurus supports standard Markdown features.
- Bold:
**bold text**-> bold text - Italic:
*italic text*-> italic text - Links :
[Links](https://docusaurus.io) Inline Code:inline code- Highlighting:
<mark>highlighted</mark>-> highlighted
Lists
- Item 1
- Item 2
- Sub-item A
- Sub-item B
2. Admonitions (Alerts)
Docusaurus has built-in support for admonitions. Use them to highlight important information.
This is a note.
This is a tip.
This is an info box.
This is a caution warning.
This is a danger alert!
Custom Titles
You can add a custom title to admonitions like this.
3. Tabs
Tabs are useful for showing different variants of code or configuration.
- Apple
- Orange
- Banana
This is an apple 🍎
This is an orange 🍊
This is a banana 🍌
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs>
<TabItem value="apple" label="Apple" default>
This is an apple 🍎
</TabItem>
...
</Tabs>
4. Code Blocks
Syntax Highlighting
function helloWorld() {
console.log("Hello, Docusaurus!");
}
Title and Line Highlighting
function MyComponent() {
return (
<div>
<h1>Hello World</h1>
<p>This line is highlighted.</p>
</div>
);
}
5. Details (Accordion)
Standard HTML <details> and <summary> work perfectly and are styled by Docusaurus.
Click to expand!
Hidden Content
You found the secret message! 📝
6. React Components
You can define or import React components directly.
How about some Docusaurus Green or Facebook Blue?
7. Assets (Images & Videos)
Local Images
Referencing images in the static folder:

MDX Images
You can also use the standard Markdown syntax or HTML for more control:
<img src="/img/logo.png" width="200" alt="Docusaurus Logo" />
8. Layout & Micro-interactions
Dividers
Use --- for a horizontal rule.
Headings
Use # through ###### for different levels. Docusaurus automatically generates a Table of Contents (TOC) on the right sidebar.
Badges
Primary Secondary Success Info Warning Danger9. Frontmatter & Sidebar Configuration
Frontmatter is the block of YAML at the top of your markdown files. It controls how the page is treated by Docusaurus.
---
id: my-doc-id
title: Page Title (shows in <title> and <h1>)
sidebar_label: Custom Sidebar Name
sidebar_position: 2
sidebar_class_name: hidden
---
Fixing Stripped Number Prefixes
Docusaurus automatically strips numbers like 01- or 10. from folder names for sorting. To keep them in the sidebar:
- Use
sidebar_labelin the file's frontmatter. - Or use a
_category_.jsonfile inside the folder for group labels:
{
"label": "01. Setup",
"position": 1
}
10. Best Practices
- Use MDX extension: Always use
.mdxif you plan to use JSX components like Tabs. - Import once: If you use many Tabs, consider adding the import to
src/theme/MDXComponentsfor global availability. - Clarity: Use Admonitions to break up long walls of text.
- Consistency: Use the same code block titles and styling throughout your documentation.